
/*
默认信息
 */
var laoding_gif = "/images/loading2.gif";
var placeholder_gif = "/images/empty.png";

/*
简单提示
 */
function Alert(bootbox,msg,func)
{
    bootbox.alert({
        buttons: {
            ok: {
                label: '确定',
                className: 'btn-info'
            }
        },
        message: msg,
        callback: function() {
           // alert('关闭了alert');
            if(func == undefined)
            {

            }
            else
            {
                func();

            }



        },
        //title: "提示",
    });


    /*
    bootbox.alert({
        buttons: {
            ok: {
                label: '我是ok按钮',
                className: 'btn-info'
            }
        },
        message: '提示信息',
        callback: function() {
            alert('关闭了alert');
        },
        title: "bootbox alert也可以添加标题哦",
    });
    */

}

/*
 错误提示
 */
function AlertError(bootbox,msg,func)
{
    bootbox.alert({
        buttons: {
            ok: {
                label: '确定',
                className: 'btn-danger'
            }
        },
        message: msg,
        callback: function() {
            // alert('关闭了alert');
            if(func == undefined)
            {

            }
            else
            {
                func();

            }



        },
        //title: "提示",
    });




}

/*
成功提示
 */
function AlertSuccess(bootbox,msg,func)
{
    bootbox.alert({
        buttons: {
            ok: {
                label: '确定',
                className: 'btn-success'
            }
        },
        message: msg,
        callback: function() {
            // alert('关闭了alert');
            if(func == undefined)
            {

            }
            else
            {
                func();

            }



        },
        //title: "提示",
    });




}

/*
* 生成弹出表单
*
 */
function generateAlertForm(alertarray)
{
    //表头
    var htmlmsg = " <form  error_type=\"right\" action=\""+alertarray.form.api+"\" role=\"form\" id=\""+alertarray.form.id+"\" name=\""+alertarray.form.name+"\">";

    //内容
    htmlmsg = htmlmsg+"<table class=\"form_table\">";

    //一行输入

    var count = alertarray.inputs.length;

    for(var i=0;i<count;i++) {

        //头显示
        htmlmsg = htmlmsg + "<tr><td class=\"t_title\">"+alertarray.inputs[i].title+":</td>";

        //输入显示
        htmlmsg = htmlmsg + "<td class=\"t_input\">";

        //标签

        if(alertarray.inputs[i].type == "show")
        {


        }

        //文本

        if(alertarray.inputs[i].type == "text")
        {


            var val = alertarray.inputs[i].value;

            if (val == undefined)
                val = "";

            var readonly = alertarray.inputs[i].readonly;

            if (readonly == undefined)
                readonly = "";



            htmlmsg = htmlmsg + "<input "+readonly+" value=\"" + val + "\" encode=\"1\" type=\"" + alertarray.inputs[i].type + "\" placeholder=\"" + alertarray.inputs[i].placeholder + "\" name=\"" + alertarray.inputs[i].name + "\" id=\"" + alertarray.inputs[i].id + "\" data-verify=\"" + alertarray.inputs[i].verify + "\">";

        }

        //选择框
        if(alertarray.inputs[i].type == "select")
        {
            var options = document.getElementById(alertarray.inputs[i].copyid).options;

            //alert(options.length);

            var selectvalue = alertarray.inputs[i].selectvalue;



            htmlmsg = htmlmsg + "<select id=\""+alertarray.inputs[i].id+"\" class=\"select\" form_name=\""+alertarray.inputs[i].form_name+"\">";

            for(var t=0;t<options.length;t++)
            {
                var checked = "";

                if(options[t].value == selectvalue)
                    checked = "selected=\"selected\"";


                htmlmsg = htmlmsg+"<option "+checked+" value=\""+options[t].value+"\">"+options[t].text+"</option>";
            }

            htmlmsg = htmlmsg +"</select>";
        }


        //图片
        if(alertarray.inputs[i].type == "img")
        {



            var clickhmtl = "onclick=\"viewUrl('"+alertarray.inputs[i].src+"')\"";

            var showsrc = alertarray.inputs[i].src;

            if(showsrc == "")
                showsrc = placeholder_gif;


            htmlmsg = htmlmsg + " <div id=\"content_theme\" class='uploaddiv'>";
            htmlmsg = htmlmsg+" <img  data-verify=\"" + alertarray.inputs[i].verify + "\" src='"+showsrc+"' form_name='"+alertarray.inputs[i].name+"' class='addimage' id='"+alertarray.inputs[i].id+"'  >";

            htmlmsg = htmlmsg+"<input type='button' value=\"上传\" id='btnid' onclick='uploadpicstart(\""+alertarray.inputs[i].id+"\")'>";

            htmlmsg = htmlmsg+"</div><br>";

        }


        //日期

        if(alertarray.inputs[i].type == "date")
        {


            var val = alertarray.inputs[i].value;

            if (val == undefined)
                val = "";

            var readonly = alertarray.inputs[i].readonly;

            if (readonly == undefined)
                readonly = "";



            htmlmsg = htmlmsg + "<input "+readonly+" value=\"" + val + "\" encode=\"1\" type=\"" + alertarray.inputs[i].type + "\" placeholder=\"" + alertarray.inputs[i].placeholder + "\" name=\"" + alertarray.inputs[i].name + "\" id=\"" + alertarray.inputs[i].id + "\" data-verify=\"" + alertarray.inputs[i].verify + "\">";

        }


        htmlmsg = htmlmsg + "</td></tr>";


    }


    //结束



    htmlmsg = htmlmsg+"</form>";
    return htmlmsg;

}

function uploadpicstart(imgid){



    $('#fileupload').attr("imgid",imgid);
    $('#fileupload').click();

}

//提示内容
function bootbox_content_alert(content)
{
    bootbox_global.dialog({
        message: content,
    });
}

//展示图片
function  viewUrl(url)
{
    bootbox_global.dialog({
        message: "<img class='dialog_img' src=\""+url+"\">",
    });
}

//显示列表信息
function getGridInfo(data,column_list)
{
    var html = "<table class=\"table_list\" id=\"table_show\">";


    html = html+"<thead><tr>";


    for (var i = 0; i < column_list.length; i++) {

        html = html+"<td>"+column_list[i].title+"</td>";


    }
    html = html+"</tr></thead>";



    html = html+"<tbody>";
    for (var t = 0; t < data.length; t++) {


        //var tbody_tr = document.createElement("tr");

        html = html+"<tr>";


        for (var i = 0; i < column_list.length; i++) {
            var dataindex = column_list[i].dataIndex;






            if(column_list[i].hasOwnProperty("td_class")  )
            {


                html = html+"<td class='"+column_list[i].td_class+"'>";
            }
            else
            {
                html = html+"<td>";
            }


            if (column_list[i].hasOwnProperty("dataSource")) {


                var datasource_function = column_list[i].dataSource;


                html = html+datasource_function(data, t, this, i);
            }
            else
                html = html+ validateGriddata(data[t][dataindex]);






            html = html+"</td>";
        }

        html = html+"</tr>";


    }

    html = html+"</tbody>";


    html = html+"</table>";

    //alert(html);

    return html;
}


//弹出内容

var showAlertflag;
var intervalid;

//设置定时器
function setTimeOutController()
{
    var tobj = document.getElementById("table_my_toast1");

    if(tobj == undefined)
        console,log("undefined");
    else
    {
        console.log(tobj);
        var columns = [
            {title : '编号',dataIndex :'User_ID',dataSource:function(data,datarow,gridobj,current_column) {

                return "<span>"+(parseInt(datarow)+1)+"</span>";
            }},
            { title: '签到时间', dataIndex: 'create_time',},
            { title: '操作人', dataIndex: 'created_by',},


        ];
       // alert(tobj);
        window.clearInterval(intervalid);
         grid_show = new Grid("/workerCheckin/getListPaging", $("#table_my_toast1"), $("#paging_my_toast1"), 1, 10, columns, "worker_id=19", 20);

        //初始化
        grid_show.Init();
        return;
    }


}

//确定是否是空
function isNull($value)
{
    if($value == null || $value == undefined || $value == "")
    return true;

    return false;

}

function getBankCashName(type)
{
   // var type = data[datarow].type;

    if(type == "withdraw_failed")
        return "提现失败";
    if(type == "withdraw_accepted")
        return "提现成功";
    if(type == "withdraw_submiting")
        return "提现审核中";
    if(type == "income_order")
        return "订单收入";
    if(type == "income_purse")
        return "红包收入";
    if(type == "income_platform")
        return "平台收入";


    return "";
}










